home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 5.7 KB | 196 lines | [TEXT/MPS ] |
- // UTearOffMenuView.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UTEAROFFMENUVIEW__
- #define __UTEAROFFMENUVIEW__
-
- // MacApp
-
- #ifndef __UCOMMAND__
- #include "UCommand.h"
- #endif
-
- #ifndef __UTRACKER__
- #include "UTracker.h"
- #endif
-
- #ifndef __UMENUVIEW__
- #include "UMenuView.h"
- #endif
-
- // Toolbox
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class TTearOffMenuView;
- class TWindow;
-
-
- //----------------------------------------------------------------------------------------
- // Constants
- //----------------------------------------------------------------------------------------
-
- const short kTearOffMargin = 10; // the slop around the displayed menu
- // within which we don't tear-off; see
- // Apple Human Interface Guidelines p. 91;
- // note: some programs (eg. HyperCard) use
- // a 15 pixel slop value
-
- const short kTearOffOffset = 3; // pixel offset from pointer to gray rgn
- // being dragged around
-
-
- //----------------------------------------------------------------------------------------
- // TShowTearOffWindowCommand: moves, shows and selects a TTearOffMenuView
- //----------------------------------------------------------------------------------------
-
- class TShowTearOffWindowCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TWindow* fTearOffWindow;
-
- CPoint fWhere;
-
-
- TShowTearOffWindowCommand();
- // Constructor
- virtual ~TShowTearOffWindowCommand();
- // Destructor
-
- void IShowTearOffWindowCommand(TWindow* tearOffWindow, CPoint where);
-
- virtual void DoIt();
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TTearOffTracker: abstract superclass which provides the ability to process a tracking
- // command immediately rather than posting it to the queue.
- //----------------------------------------------------------------------------------------
-
- class TTearOffMenuViewTracker : public TTracker
- {
- MA_DECLARE_CLASS;
-
- public:
-
- TTearOffMenuViewTracker();
- // Empty constructor to satisfy compiler.
- virtual ~TTearOffMenuViewTracker();
- // Destructor
-
- void ITearOffMenuViewTracker(CommandNumber itsCommandNumber,
- TCommandHandler* itsContext,
- Boolean canUndo,
- Boolean causesChange,
- TObject* objectToNotify,
- TView* itsView,
- TScroller* itsScroller,
- const VPoint& itsMouse);
-
- virtual Boolean IsReadyToPost(); // override
- // Process the command immediately rather than posting to the command queue.
- };
-
- //----------------------------------------------------------------------------------------
- // TTearOffTracker: abstract superclass providing basic tear-off menu tracking: tracks the
- // grey outline of the menu around the screen
- //----------------------------------------------------------------------------------------
-
- class TTearOffTracker : public TTearOffMenuViewTracker
- {
- MA_DECLARE_CLASS;
-
- public:
- TTearOffMenuView* fTearOffMenu;
-
- RgnHandle fTearOffWindowOutline;
-
- Boolean fExitTracking;
-
- CPoint fOrigin;
-
- TTearOffTracker();
- // Constructor
-
- void ITearOffTracker(CPoint hitPt, TTearOffMenuView* tearOffMenu);
-
- virtual ~TTearOffTracker();
-
- virtual void DoIt();
-
- virtual void TrackFeedback(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn);
-
- virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
- VPoint& anchorPoint,
- VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove);
-
- virtual Boolean IsDoneTracking();
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TTearOffMenuView: abstract superclass providing basic tear-off menu behavior
- //----------------------------------------------------------------------------------------
-
- class TTearOffMenuView : public TMenuView
- {
- MA_DECLARE_CLASS;
-
- public:
- RgnHandle fTearOffTrackingRegion;
-
- TTearOffTracker* fTearOffTracker;
-
- TWindow* fTearOffWindow;
-
- TTearOffMenuView();
- // Constructor
-
- void ITearOffMenuView(ResNumber rsrcID,
- short menuWidth,
- short menuHeight,
- TWindow* tearOffWindow);
-
- virtual void InstallTearOffTracker();
- // For the sake of efficiency when tracking a tear-off, we'll create the tear-off
- // tracker and keep it with us, so we don't need to allocate a new tracker every
- // time we tear off a menu. If you want a different tracker in your subclass of
- // TTearOffMenuView, then override this method.
-
- virtual ~TTearOffMenuView();
-
- virtual void HandleChooseMessage(short message,
- MenuRef theMenu,
- CRect& menuRect,
- CPoint hitPt,
- short& whichItem);
- // initiates tracking if mouse is in fTearOffTrackingRegion
-
- virtual RgnHandle GetTearOffTrackingRegion(const CRect& menuRect);
- // accessor for fTearOffTrackingRegion: a rgn that represents the desktop less the
- // menu CRect (with some buffer area around the menu CRect). This is useful for
- // testing whether tracking should occur because the mouse just might be in the
- // menu bar (which isn't in the desktop & isn't in the menu CRect) and so tracking
- // should not occur while the mouse is in the menu bar (MenuSelect does that
- // tracking just fine).
-
- };
-
-
- #endif
-
-